package com.ikun.starters.jwt.auto;

import com.ikun.starters.jwt.impl.JwtMemberDataService;
import com.ikun.starters.jwt.properties.TokenConfigurationProperties;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * @author ximeng
 * @title: JwtAutoConfiguration
 */
@SpringBootConfiguration
@ConditionalOnClass(JwtMemberDataService.class)
@EnableConfigurationProperties(TokenConfigurationProperties.class)  //引入可变的参数
public class JwtAutoConfiguration {

    @Bean
    public JwtMemberDataService jwtMemberDataService(TokenConfigurationProperties tokenConfigurationProperties) {
        return new JwtMemberDataService(tokenConfigurationProperties.getExpireTime(),tokenConfigurationProperties.getTokenSignKey());
    }

}
